package testcase.app;

import org.json.JSONArray;
import org.testng.Assert;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import api.app.Banner;
import common.Host;
import common.TestData;

/**
 * 帮忙医获取banner信息接口测试用例
 * @author lipeng
 *
 */
public class TestBanner
{
	/**
	 * 帮忙医获取banner信息接口测试环境数据驱动
	 * @return  
	 * @throws Exception
	 */
    @DataProvider(name = "Test")
    public static String[][] testBannerDataProvider() throws Exception{
    	Host.setup("Test");
    	TestData td = new TestData("app/TestBanner.xml");
    	return td.getParam();
    }
    
    @Test(dataProvider="Test",groups={"Test"})
    public void testBannerTestCase(String casename,String token,String typeNo)throws Exception{
    	//调用接口并将接口返回数据转换成json格式
    	String result = Banner.get(token, typeNo);
    	JSONArray jsonResult;
    	if(result == null || result.isEmpty()){
    		jsonResult = null;
    	}
    	else {
			jsonResult = new JSONArray(result);
		}
    	
    	//设置检查点
    	switch (casename)
		{
			case "Success":
				Assert.assertEquals(jsonResult.getJSONObject(0).getString("ImgUrl").isEmpty(),false);
				break;

			default:
				break;
		}
    }
}
